using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;

namespace Model
{
    public partial class Model1 : DbContext
    {
        public Model1()
            : base("name=Model1")
        {
        }

        public virtual DbSet<TBRecord> TBRecord { get; set; }
        public virtual DbSet<TBUser> TBUser { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<TBRecord>()
                .Property(e => e.Id)
                .IsUnicode(false);

            modelBuilder.Entity<TBRecord>()
                .Property(e => e.UserId)
                .IsUnicode(false);

            modelBuilder.Entity<TBRecord>()
                .Property(e => e.District)
                .IsUnicode(false);

            modelBuilder.Entity<TBRecord>()
                .Property(e => e.Name)
                .IsUnicode(false);

            modelBuilder.Entity<TBRecord>()
                .Property(e => e.Functional)
                .IsUnicode(false);

            modelBuilder.Entity<TBRecord>()
                .Property(e => e.Remarks)
                .IsUnicode(false);

            modelBuilder.Entity<TBUser>()
                .Property(e => e.Id)
                .IsUnicode(false);

            modelBuilder.Entity<TBUser>()
                .Property(e => e.Name)
                .IsUnicode(false);

            modelBuilder.Entity<TBUser>()
                .Property(e => e.Avatar)
                .IsUnicode(false);

            modelBuilder.Entity<TBUser>()
                .Property(e => e.Password)
                .IsUnicode(false);

            modelBuilder.Entity<TBUser>()
                .Property(e => e.PhoneNumber)
                .IsUnicode(false);

            modelBuilder.Entity<TBUser>()
                .Property(e => e.Email)
                .IsUnicode(false);

            modelBuilder.Entity<TBUser>()
                .HasMany(e => e.TBRecord)
                .WithRequired(e => e.TBUser)
                .HasForeignKey(e => e.UserId)
                .WillCascadeOnDelete(false);
        }
    }
}
